import ACT from '../actionType'
import { connect } from 'react-redux'

/**
 *用户列表模块action
 */
export const action = {
  getCourseList: param => {
    return {
      types: [ACT.COURSE_COURSELIST_GET],
      promise: ajax => ajax.post('/course/courseList', { ...param }),
      meta: param
    }
  }
}

//###########
//固定数据
//###########
//用户列表--表格头thead
const courseTableHeader = [
  {
    title: '课程名称',
    dataIndex: 'name',
    key: 'name',
    sorter: true
  },
  {
    title: '价格',
    dataIndex: 'rate',
    key: 'rate'
  },
  {
    title: '针对年级',
    dataIndex: 'grade',
    key: 'grade'
  },
  {
    title: '课程品类',
    dataIndex: 'category',
    key: 'category'
  },
  {
    title: '操作',
    dataIndex: 'id',
    key: 'id'
  }
]

/**
 * 取出数据和绑定方法
 */
export const reduce = connect(
  //取出数据
  state => ({
    //all: console.log('state', state) || state,
    courseList: state.Course.courseList,
    courseTableHeader
  }),
  action
)
